//1. set this to the desired path
cd "~/Desktop/LAP_PSRM_Replication/"

//2. Import the core replication file
use "LAP_Replication_RCVs_US.dta", clear

//3. Only keep the passage votes
//sg_votes: 1 = procedural, 2 = passage, 3 = amendment, 4 = committee
keep if sg_vote == 2

//4. Collapse this file down to find the average party difference of each chamber/congress
collapse (mean) party_diff, by(congress chamber)


//5. Bring in the congressional expenditures of different lobbying groups
merge m:1 congress using "LAP_Replication_lobbyingexpenditures_US.dta", nogen

//6. calculate correlations mentioned in the main text
corr party_diff amount_12d_B amount_12d_G amount_12d_N totalamount if chamber ==  "house"
corr party_diff amount_12d_B amount_12d_G amount_12d_N totalamount if chamber == "senate"


//7. Transform the expenditures into Billions
gen billz_N = amount_12d_N/1000000000
gen billz_G = amount_12d_G/1000000000
gen billz_B = amount_12d_B/1000000000


//8. create the measures to be placed in stackable bar charts
gen billz_N1 = billz_B + billz_G + billz_N
gen billz_G1 = billz_B + billz_G

//9. Create the figure
twoway ///
(bar billz_N1 year , fcolor(maroon) lcolor(gs8) lwidth(thin) sort) ///
(bar billz_G1 year , fcolor(dkgreen) lcolor(gs8) lwidth(thin) sort) ///
(bar billz_B year , sort fcolor(navy) lcolor(gs8) lwidth(thin)) ///
(line party_diff year if chamber == "house", sort yaxis(2) lcolor(black) lpattern(dash)) ///
(line party_diff year if chamber == "senate", sort yaxis(2) lcolor(gs4) lpattern(solid)), ///
ytitle("Lobbying Expenditures (2012$, billions)") ytitle("Average Party Difference on Passage votes", axis(2))  ylabel(0(.2).8, axis(2)) ///
xtitle("Year") xlabel(1999(2)2014,angle(45)) ylabel(2(2)12, axis(1)) ///
legend(order (3 "Business" 2 "Government" 1 "Non-Profit" 4 "House P.D." 5 "Senate P.D."))

